class UserTagLib {
  def displayImage = {attrs, body->
    def user = attrs["user"]
    def filename = attrs["filename"]

    if(filename){
      def extension = filename.split("\\.")[-1]
      def userDir = "images/users/${user}"

      switch(extension.toUpperCase()){
        case ["JPG", "PNG", "GIF"]:
             def html = """
             <p>
               <img src="${createLinkTo(dir:''+userDir,
                                        file:''+filename)}"
                    width="150"
                    height="150"
                    alt="${filename}"
                    title="${filename}" />
             </p>
             """

             out << html
             break
        default:
             out << "<p>wrong extension</p>"
             break
      }
    }else{
      out << "<!-- no file -->"
    }
  }
}
